home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / xpcom / nsIOutputStream.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  10KB  |  254 lines

  1. /*
  2.  * DO NOT EDIT.  THIS FILE IS GENERATED FROM nsIOutputStream.idl
  3.  */
  4.  
  5. #ifndef __gen_nsIOutputStream_h__
  6. #define __gen_nsIOutputStream_h__
  7.  
  8.  
  9. #ifndef __gen_nsISupports_h__
  10. #include "nsISupports.h"
  11. #endif
  12.  
  13. /* For IDL files that don't want to include root IDL files. */
  14. #ifndef NS_NO_VTABLE
  15. #define NS_NO_VTABLE
  16. #endif
  17. class nsIOutputStream; /* forward declaration */
  18.  
  19. class nsIInputStream; /* forward declaration */
  20.  
  21. /**
  22.  * The signature for the reader function passed to WriteSegments. This 
  23.  * is the "provider" of data that gets written into the stream's buffer.
  24.  *
  25.  * @param aOutStream stream being written to
  26.  * @param aClosure opaque parameter passed to WriteSegments
  27.  * @param aToSegment pointer to memory owned by the output stream
  28.  * @param aFromOffset amount already written (since WriteSegments was called)
  29.  * @param aCount length of toSegment
  30.  * @param aReadCount number of bytes written
  31.  *
  32.  * Implementers should return the following:
  33.  *
  34.  * @return NS_OK and (*aReadCount > 0) if successfully provided some data
  35.  * @return NS_OK and (*aReadCount = 0) or
  36.  * @return <any-error> if not interested in providing any data
  37.  *
  38.  * Errors are never passed to the caller of WriteSegments.
  39.  *
  40.  * @status FROZEN
  41.  */
  42. typedef NS_CALLBACK(nsReadSegmentFun)(nsIOutputStream *aOutStream,
  43.                                       void *aClosure,
  44.                                       char *aToSegment,
  45.                                       PRUint32 aFromOffset,
  46.                                       PRUint32 aCount,
  47.                                       PRUint32 *aReadCount);
  48.  
  49. /* starting interface:    nsIOutputStream */
  50. #define NS_IOUTPUTSTREAM_IID_STR "0d0acd2a-61b4-11d4-9877-00c04fa0cf4a"
  51.  
  52. #define NS_IOUTPUTSTREAM_IID \
  53.   {0x0d0acd2a, 0x61b4, 0x11d4, \
  54.     { 0x98, 0x77, 0x00, 0xc0, 0x4f, 0xa0, 0xcf, 0x4a }}
  55.  
  56. class NS_NO_VTABLE nsIOutputStream : public nsISupports {
  57.  public: 
  58.  
  59.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IOUTPUTSTREAM_IID)
  60.  
  61.   /**
  62.  * nsIOutputStream
  63.  *
  64.  * @status FROZEN
  65.  */
  66. /** 
  67.      * Close the stream. Forces the output stream to flush any buffered data.
  68.      *
  69.      * @throws NS_BASE_STREAM_WOULD_BLOCK if unable to flush without blocking 
  70.      *   the calling thread (non-blocking mode only)
  71.      */
  72.   /* void close (); */
  73.   NS_IMETHOD Close(void) = 0;
  74.  
  75.   /**
  76.      * Flush the stream.
  77.      *
  78.      * @throws NS_BASE_STREAM_WOULD_BLOCK if unable to flush without blocking 
  79.      *   the calling thread (non-blocking mode only)
  80.      */
  81.   /* void flush (); */
  82.   NS_IMETHOD Flush(void) = 0;
  83.  
  84.   /**
  85.      * Write data into the stream.
  86.      *
  87.      * @param aBuf the buffer containing the data to be written
  88.      * @param aCount the maximum number of bytes to be written
  89.      *
  90.      * @return number of bytes written (may be less than aCount)
  91.      *
  92.      * @throws NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would
  93.      *   block the calling thread (non-blocking mode only)
  94.      * @throws <other-error> on failure
  95.      */
  96.   /* unsigned long write (in string aBuf, in unsigned long aCount); */
  97.   NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval) = 0;
  98.  
  99.   /**
  100.      * Writes data into the stream from an input stream.
  101.      *
  102.      * @param aFromStream the stream containing the data to be written
  103.      * @param aCount the maximum number of bytes to be written
  104.      *
  105.      * @return number of bytes written (may be less than aCount)
  106.      *
  107.      * @throws NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would
  108.      *    block the calling thread (non-blocking mode only)
  109.      * @throws <other-error> on failure
  110.      *
  111.      * NOTE: This method is defined by this interface in order to allow the
  112.      * output stream to efficiently copy the data from the input stream into
  113.      * its internal buffer (if any). If this method was provided as an external
  114.      * facility, a separate char* buffer would need to be used in order to call
  115.      * the output stream's other Write method.
  116.      */
  117.   /* unsigned long writeFrom (in nsIInputStream aFromStream, in unsigned long aCount); */
  118.   NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval) = 0;
  119.  
  120.   /**
  121.      * Low-level write method that has access to the stream's underlying buffer.
  122.      * The reader function may be called multiple times for segmented buffers.
  123.      * WriteSegments is expected to keep calling the reader until either there
  124.      * is nothing left to write or the reader returns an error.  WriteSegments
  125.      * should not call the reader with zero bytes to provide.
  126.      *
  127.      * @param aReader the "provider" of the data to be written
  128.      * @param aClosure opaque parameter passed to reader
  129.      * @param aCount the maximum number of bytes to be written
  130.      *
  131.      * @return number of bytes written (may be less than aCount)
  132.      *
  133.      * @throws NS_BASE_STREAM_WOULD_BLOCK if writing to the output stream would
  134.      *    block the calling thread (non-blocking mode only)
  135.      * @throws <other-error> on failure
  136.      *
  137.      * NOTE: this function may be unimplemented if a stream has no underlying
  138.      * buffer (e.g., socket output stream).
  139.      */
  140.   /* [noscript] unsigned long writeSegments (in nsReadSegmentFun aReader, in voidPtr aClosure, in unsigned long aCount); */
  141.   NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval) = 0;
  142.  
  143.   /**
  144.      * @return true if stream is non-blocking
  145.      *
  146.      * NOTE: writing to a blocking output stream will block the calling thread
  147.      * until all given data can be consumed by the stream.
  148.      */
  149.   /* boolean isNonBlocking (); */
  150.   NS_IMETHOD IsNonBlocking(PRBool *_retval) = 0;
  151.  
  152. };
  153.  
  154. /* Use this macro when declaring classes that implement this interface. */
  155. #define NS_DECL_NSIOUTPUTSTREAM \
  156.   NS_IMETHOD Close(void); \
  157.   NS_IMETHOD Flush(void); \
  158.   NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval); \
  159.   NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval); \
  160.   NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval); \
  161.   NS_IMETHOD IsNonBlocking(PRBool *_retval); 
  162.  
  163. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  164. #define NS_FORWARD_NSIOUTPUTSTREAM(_to) \
  165.   NS_IMETHOD Close(void) { return _to Close(); } \
  166.   NS_IMETHOD Flush(void) { return _to Flush(); } \
  167.   NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval) { return _to Write(aBuf, aCount, _retval); } \
  168.   NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval) { return _to WriteFrom(aFromStream, aCount, _retval); } \
  169.   NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return _to WriteSegments(aReader, aClosure, aCount, _retval); } \
  170.   NS_IMETHOD IsNonBlocking(PRBool *_retval) { return _to IsNonBlocking(_retval); } 
  171.  
  172. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  173. #define NS_FORWARD_SAFE_NSIOUTPUTSTREAM(_to) \
  174.   NS_IMETHOD Close(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Close(); } \
  175.   NS_IMETHOD Flush(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Flush(); } \
  176.   NS_IMETHOD Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Write(aBuf, aCount, _retval); } \
  177.   NS_IMETHOD WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteFrom(aFromStream, aCount, _retval); } \
  178.   NS_IMETHOD WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->WriteSegments(aReader, aClosure, aCount, _retval); } \
  179.   NS_IMETHOD IsNonBlocking(PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsNonBlocking(_retval); } 
  180.  
  181. #if 0
  182. /* Use the code below as a template for the implementation class for this interface. */
  183.  
  184. /* Header file */
  185. class nsOutputStream : public nsIOutputStream
  186. {
  187. public:
  188.   NS_DECL_ISUPPORTS
  189.   NS_DECL_NSIOUTPUTSTREAM
  190.  
  191.   nsOutputStream();
  192.  
  193. private:
  194.   ~nsOutputStream();
  195.  
  196. protected:
  197.   /* additional members */
  198. };
  199.  
  200. /* Implementation file */
  201. NS_IMPL_ISUPPORTS1(nsOutputStream, nsIOutputStream)
  202.  
  203. nsOutputStream::nsOutputStream()
  204. {
  205.   /* member initializers and constructor code */
  206. }
  207.  
  208. nsOutputStream::~nsOutputStream()
  209. {
  210.   /* destructor code */
  211. }
  212.  
  213. /* void close (); */
  214. NS_IMETHODIMP nsOutputStream::Close()
  215. {
  216.     return NS_ERROR_NOT_IMPLEMENTED;
  217. }
  218.  
  219. /* void flush (); */
  220. NS_IMETHODIMP nsOutputStream::Flush()
  221. {
  222.     return NS_ERROR_NOT_IMPLEMENTED;
  223. }
  224.  
  225. /* unsigned long write (in string aBuf, in unsigned long aCount); */
  226. NS_IMETHODIMP nsOutputStream::Write(const char *aBuf, PRUint32 aCount, PRUint32 *_retval)
  227. {
  228.     return NS_ERROR_NOT_IMPLEMENTED;
  229. }
  230.  
  231. /* unsigned long writeFrom (in nsIInputStream aFromStream, in unsigned long aCount); */
  232. NS_IMETHODIMP nsOutputStream::WriteFrom(nsIInputStream *aFromStream, PRUint32 aCount, PRUint32 *_retval)
  233. {
  234.     return NS_ERROR_NOT_IMPLEMENTED;
  235. }
  236.  
  237. /* [noscript] unsigned long writeSegments (in nsReadSegmentFun aReader, in voidPtr aClosure, in unsigned long aCount); */
  238. NS_IMETHODIMP nsOutputStream::WriteSegments(nsReadSegmentFun aReader, void * aClosure, PRUint32 aCount, PRUint32 *_retval)
  239. {
  240.     return NS_ERROR_NOT_IMPLEMENTED;
  241. }
  242.  
  243. /* boolean isNonBlocking (); */
  244. NS_IMETHODIMP nsOutputStream::IsNonBlocking(PRBool *_retval)
  245. {
  246.     return NS_ERROR_NOT_IMPLEMENTED;
  247. }
  248.  
  249. /* End of implementation class template. */
  250. #endif
  251.  
  252.  
  253. #endif /* __gen_nsIOutputStream_h__ */
  254.